package com.bc.trade.channel.yufu;

import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.bc.common.CommonEnum.Resp;
import com.bc.common.PayType;
import com.bc.common.message.DFReq;
import com.bc.common.message.DFResp;
import com.bc.trade.channel.IChannel;
import com.bc.trade.config.SystemConfig;
import com.bc.trade.message.QueryCardInfoReq;
import com.bc.trade.message.QueryCardInfoResp;
import com.bc.trade.message.QueryOrderResp;
import com.bc.trade.message.QuickPayReq;
import com.bc.trade.message.QuickPayResp;
import com.bc.trade.message.QuickPaySetReq;
import com.bc.trade.message.QuickPaySetResp;
import com.bc.trade.message.RefundReq;
import com.bc.trade.message.RefundResp;
import com.bc.trade.message.SendSMSReq;
import com.bc.trade.message.SendSMSResp;
import com.bc.trade.message.UnionPayReq;
import com.bc.trade.message.UnionPayResp;
import com.bc.trade.model.TradeOrder;
import com.bc.trade.model.TradeStrategy;
import com.fs.common.util.FSDate;
import com.fs.common.util.FSLog;
import com.fs.common.util.FSString;
import com.jfinal.kit.StrKit;
import com.yufusoft.payplatform.security.cipher.YufuCipher;
import com.yufusoft.payplatform.security.vo.ParamPacket;

public class YFChannel implements IChannel {

	private static final String UNPAY_URL = SystemConfig.channelConfig.get("YF_unionpay_url");
	private static final String TOKEN_URL = SystemConfig.channelConfig.get("YF_tokenUrl");
	private static final String REFUND_URL = SystemConfig.channelConfig.get("YF_refund_url");
	private static final String QUERY_URL = SystemConfig.channelConfig.get("YF_query_url");
	private static final String DF_URL = SystemConfig.channelConfig.get("YF_df");
	private static final String DF_QUERY = SystemConfig.channelConfig.get("YF_df_query");
	private static final String QUICK_PAY_SET_URL = SystemConfig.channelConfig.get("YF_quickpay_set_url");
	private static final String QUICK_PAY_URL = SystemConfig.channelConfig.get("YF_quickpay_url");
	private static final String SENDSMS_URL = SystemConfig.channelConfig.get("YF_sendsms_url");
	private static final String QUERY_CARD_INFO_URL = SystemConfig.channelConfig.get("YF_query_card_info_url");

	@Override
	public QueryOrderResp query(TradeOrder order) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + order.getChannelCode());
		QueryOrderResp rsp = new QueryOrderResp();
		HashMap<String, String> data = new HashMap<>();
		data.put("version", "1.0.0");
		if (order.getPayType().equals(PayType.REFUND)) {
			data.put("transType", "02");
		} else {
			data.put("transType", "01");
		}
		data.put("merchantId", channelMerchCode);
		data.put("oriMerchantOrderId", order.getOrderNo());
		data.put("oriMerchantOrderTime",
				FSDate.formatDateTime(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmss"));
		YufuCipher cipher = YFUtil.getCipherInstance(order.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(QUERY_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("------- 收到YF查询响应 ---------\r\n" + retBizData);
		String respCode = retBizData.get("respCode");
		if (respCode.equals("0000")) {
			String transStatus = retBizData.get("transStatus");
			String bpSerialNum = retBizData.get("bpSerialNum");
			if (transStatus.equals("01")) {
				rsp.setOriginalRespCode(Resp.Success.getCode());
				rsp.setOriginalRespMsg(Resp.Success.getMsg());
				rsp.setPayTime(FSDate.formatDateTime(retBizData.get("transTime"), "yyyyMMddHHmmss", "yyyy-MM-dd HH:mm:ss"));
				order.setChannelOrderNo(bpSerialNum);
			} else if (transStatus.matches("03|04")) {
				rsp.setOriginalRespCode(Resp.InProcess.getCode());
				rsp.setOriginalRespMsg(Resp.InProcess.getMsg());
				order.setChannelOrderNo(bpSerialNum);
			} else {
				rsp.setOriginalRespCode(Resp.Fail.getCode());
				rsp.setOriginalRespMsg(Resp.Fail.getMsg());
			}
		} else {
			rsp.setOriginalRespCode(Resp.InProcess.getCode());
			rsp.setOriginalRespMsg(Resp.InProcess.getMsg());
		}
		return rsp;
	}

	@Override
	public DFResp df(DFReq req, TradeOrder order) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + order.getChannelCode());
		DFResp rsp = new DFResp(req);
		HashMap<String, String> data = new HashMap<>();
		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("merchantOrderId", order.getOrderNo());
		data.put("merchantOrderTime",
				FSDate.formatDateTime(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmss"));
		JSONObject payInfo = new JSONObject();
		payInfo.put("accountName", req.getAccountName());
		payInfo.put("accountNo", req.getAccountCardNo());
		payInfo.put("bankName", req.getBankName());
		payInfo.put("amt", req.getAmount());
		if (req.getPayType().equals(PayType.DF_PERSONAL)) { // 对私
			payInfo.put("pblFlag", "02");// 对私
		} else {
			payInfo.put("pblFlag", "01");// 对公
			payInfo.put("province", req.getProvince());
			payInfo.put("city", req.getCity());
			payInfo.put("branchName", req.getBranchName());
		}
		payInfo.put("remark", req.getRemark());
		data.put("payInfo", payInfo.toJSONString());
		data.put("backUrl", YFUtil.getNotifyUrl(order.getChannelCode()));
		YufuCipher cipher = YFUtil.getCipherInstance(order.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(DF_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("-----收到代付请求响应-------\r\n" + retBizData);
		if ("0000".equals(retBizData.get("respCode"))) {
			order.setChannelOrderNo(retBizData.get("bpSerialNum"));
			String transStatus = retBizData.get("transStatus");
			if (transStatus.matches("02|03|05")) {
				rsp.setCodeAndMsg(Resp.InProcess.getCode(), Resp.InProcess.getMsg());
			} else {
				rsp.setCodeAndMsg(Resp.Fail.getCode(), Resp.Fail.getMsg());
			}
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), "CH-" + retBizData.get("respDesc"));
		}
		return rsp;
	}

	@Override
	public UnionPayResp unionpay(UnionPayReq req, TradeOrder order) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + order.getChannelCode());
		String channelMerchName = SystemConfig.channelConfig.get("YF_merchName_" + order.getChannelCode());
		UnionPayResp rsp = new UnionPayResp(req);
		HashMap<String, String> data = new HashMap<>();
		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("merchantOrderId", order.getOrderNo());
		data.put("merchantOrderTime",
				FSDate.formatDateTime(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmss"));
		data.put("merchantOrderAmt", req.getAmount());
		data.put("merchantOrderCurrency", "156");
		data.put("gwType", "02");
		data.put("frontUrl", req.getCallbackUrl());
		data.put("backUrl", YFUtil.getNotifyUrl(order.getChannelCode()));
		data.put("bankId", req.getBankType());
		data.put("userType", "01"); // 01-个人，02-企业
		data.put("merchantOrderDesc", req.getRemark());
		data.put("merchantUserId", order.getMerchCode()); // 共享用户商户平台必填
		JSONArray settleInfo = new JSONArray();
		JSONObject info = new JSONObject();
		info.put("merchantId", channelMerchCode);
		info.put("merchantName", channelMerchName);
		info.put("orderAmt", req.getAmount());
		info.put("sumGoodsName", req.getGoodsName());
		data.put("merchantSettleInfo", settleInfo.toJSONString());
		YufuCipher cipher = YFUtil.getCipherInstance(order.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		FSLog.api.info("发送到渠道数据为：" + sendData);
		String sendResult = YFUtil.doPost(UNPAY_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("---------收到网银支付请求响应解密 ---------\r\n" + retBizData);
		String respCode = retBizData.get("respCode");
		String respDesc = retBizData.get("respDesc");
		if ("0000".equals(respCode)) {
			ParamPacket pp = cipher.doPack(retBizData);
			TreeMap<String, String> result = new TreeMap<>();
			result.put("merchantId", channelMerchCode);
			result.put("data", pp.getData());
			result.put("enc", pp.getEnc());
			result.put("sign", pp.getSign());
			String retString = JSONObject.toJSONString(result);
			TreeMap<String, String> retMap = JSONObject.parseObject(retString,
					new TypeReference<TreeMap<String, String>>() {
					});
			String html = FSString.createRedirectHtml(retMap, TOKEN_URL);
			rsp.setHtml(html);
			rsp.setType("0");
			rsp.setCodeAndMsg(Resp.Success.getCode(), Resp.Success.getMsg());
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), respCode + "-" + respDesc);
		}
		return rsp;
	}

	@Override
	public QuickPaySetResp quickPaySet(QuickPaySetReq req, TradeOrder order) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + order.getChannelCode());
		String channelMerchName = SystemConfig.channelConfig.get("YF_merchName_" + order.getChannelCode());
		QuickPaySetResp rsp = new QuickPaySetResp(req);
		HashMap<String, String> data = new HashMap<>();

		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("merchantOrderId", order.getOrderNo());
		data.put("merchantOrderTime",
				FSDate.formatDateTime(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmss"));
		data.put("merchantOrderAmt", req.getAmount());
		data.put("merchantOrderCurrency", "156");
		data.put("gwType", "04");
		data.put("backUrl", YFUtil.getNotifyUrl(order.getChannelCode()));
		data.put("userType", "01"); // 01-个人,02-企业,只做个人不做企业
		data.put("merchantUserId", req.getCertNo());// merchantUserId上送身份证号，方便查询卡信息时使用
		data.put("merchantOrderDesc", req.getGoodsName());

		JSONArray settleInfoList = new JSONArray();
		JSONObject settleInfo = new JSONObject();
		settleInfo.put("merchantId", channelMerchCode);
		settleInfo.put("merchantName", channelMerchName);
		settleInfo.put("orderAmt", req.getAmount());
		settleInfo.put("sumGoodsName", req.getGoodsName());
		settleInfoList.add(settleInfo);
		data.put("merchantSettleInfo", settleInfoList.toJSONString());

		if (StrKit.notBlank(req.getVerifyId())) {
			data.put("verifyId", req.getVerifyId());
		} else {
			JSONArray payCardList = new JSONArray();
			JSONObject payCard = new JSONObject();
			payCard.put("cardNo", req.getCardNo());
			payCard.put("cardType", req.getCardType().equals("0") ? "P1" : "P2");
			payCard.put("bankNo", req.getBankType());
			payCard.put("certNo", req.getCertNo());
			payCard.put("certType", req.getCertType());
			payCard.put("name", req.getName());
			payCard.put("phone", req.getPhone());
			if (req.getCardType().equals("1")) {
				payCard.put("cvn2", req.getCvn2());
				payCard.put("expired", req.getExpired());
			}
			payCardList.add(payCard);
			data.put("payCardList", payCardList.toJSONString());
		}

		YufuCipher cipher = YFUtil.getCipherInstance(order.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(QUICK_PAY_SET_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("------- 裕福快捷支付制单请求响应解密 -------\r\n" + retBizData);
		String respCode = retBizData.get("respCode");
		String respDesc = retBizData.get("respDesc");
		if ("0000".equals(respCode)) {
			String token = retBizData.get("token");
			rsp.setToken(token);
			rsp.setCodeAndMsg(Resp.Success.getCode(), Resp.Success.getMsg());
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), respCode + "-" + respDesc);
		}
		return rsp;
	}

	@Override
	public QuickPayResp quickPay(QuickPayReq req, TradeOrder order) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + order.getChannelCode());
		QuickPayResp rsp = new QuickPayResp(req);
		HashMap<String, String> data = new HashMap<>();

		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("token", req.getToken());
		data.put("smsCode", req.getSmsCode());

		YufuCipher cipher = YFUtil.getCipherInstance(order.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(QUICK_PAY_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("------- YF快捷支付请求响应解密 -------\r\n" + retBizData);
		String respCode = retBizData.get("respCode");
		String respDesc = retBizData.get("respDesc");
		if ("0000".equals(respCode)) {
			// transStatus 01:支付成功 02:支付失败 03:支付中 04:支付风险审核中 05:支付取消
			String transStatus = retBizData.get("transStatus");
			if ("01".equals(transStatus)) {
				rsp.setCodeAndMsg(Resp.Success.getCode(), Resp.Success.getMsg());
			} else if (transStatus.matches("03|04")) {
				rsp.setCodeAndMsg(Resp.InProcess.getCode(), Resp.InProcess.getMsg());
			} else {
				rsp.setCodeAndMsg(Resp.Fail.getCode(), Resp.Fail.getMsg());
			}
		} else if ("0030004".equals(respCode)) {
			rsp.setCodeAndMsg(Resp.CodeHasExpired.getCode(), Resp.CodeHasExpired.getMsg());
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), respCode + "-" + respDesc);
		}
		return rsp;
	}

	@Override
	public RefundResp refund(RefundReq req, TradeOrder refundOrder, TradeOrder orignOrder) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + refundOrder.getChannelCode());
		RefundResp rsp = new RefundResp(req);
		HashMap<String, String> data = new HashMap<>();
		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("settleMerchantId", channelMerchCode);
		data.put("merchantOrderId", refundOrder.getOrderNo());
		data.put("merchantOrderTime",
				FSDate.formatDateTime(refundOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmss"));
		data.put("merchantOrderAmt", String.valueOf(refundOrder.getAmount()));
		data.put("merchantOrderDesc", refundOrder.getRemark());
		if (req.getPayType().equals(PayType.UNION_PAY)) {
			data.put("gwType", "01"); // 01:web
		} else {
			data.put("gwType", "04"); // 04:快捷
		}
		data.put("orgBpSerialNum", orignOrder.getChannelOrderNo()); // 原业务流水号
		data.put("orgTransTime",
				FSDate.formatDateTime(orignOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmss"));
		data.put("backUrl", YFUtil.getNotifyUrl(refundOrder.getChannelCode()));
		YufuCipher cipher = YFUtil.getCipherInstance(refundOrder.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(REFUND_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("-------YF退款请求响应解密 -------\r\b" + retBizData);
		String respCode = retBizData.get("respCode");
		String respDesc = retBizData.get("respDesc");
		if ("0000".equals(respCode)) {
			String transStatus = retBizData.get("transStatus");
			if (transStatus.matches("01|03")) {
				rsp.setCodeAndMsg(Resp.InProcess.getCode(), Resp.InProcess.getMsg());
			} else {
				rsp.setCodeAndMsg(Resp.Fail.getCode(), respDesc);
			}
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), respCode + "-" + respDesc);
		}
		return rsp;
	}

	@Override
	public QueryOrderResp dfQuery(TradeOrder order) throws Exception {
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + order.getChannelCode());
		QueryOrderResp rsp = new QueryOrderResp();
		HashMap<String, String> data = new HashMap<>();
		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("merchantOrderId", order.getOrderNo());
		YufuCipher cipher = YFUtil.getCipherInstance(order.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(DF_QUERY, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("------- YF代付查询请求响应 -------\r\n" + retBizData);
		if (retBizData.get("respCode").equals("0000")) {
			order.setChannelOrderNo(retBizData.get("bpSerialNum"));
			String transStatus = retBizData.get("transStatus");
			if (transStatus.matches("05")) {
				rsp.setOriginalRespCode(Resp.Success.getCode());
				rsp.setOriginalRespMsg(Resp.Success.getMsg());
			} else if (transStatus.matches("02|03")) {
				rsp.setOriginalRespCode(Resp.InProcess.getCode());
				rsp.setOriginalRespMsg(Resp.InProcess.getMsg());
			} else {
				rsp.setOriginalRespCode(Resp.Fail.getCode());
				rsp.setOriginalRespMsg(Resp.Fail.getMsg());
			}
		} else {
			rsp.setOriginalRespCode(Resp.Fail.getCode());
			rsp.setOriginalRespMsg(retBizData.get("respDesc"));
		}
		return rsp;
	}

	@Override
	public SendSMSResp sendSMS(SendSMSReq req) throws Exception {
		TradeStrategy ts = TradeStrategy.dao.selectFromRedis(req.getMerchCode(), PayType.QUICK_PAY_SET);
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + ts.getChannelCode());
		SendSMSResp rsp = new SendSMSResp(req);
		HashMap<String, String> data = new HashMap<>();

		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("token", req.getToken());

		YufuCipher cipher = YFUtil.getCipherInstance(ts.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(SENDSMS_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("-------- YF快捷支付发送短信请求响应 -------\r\n" + retBizData);
		String respCode = retBizData.get("respCode");
		String respDesc = retBizData.get("respDesc");
		if ("0000".equals(respCode)) {
			rsp.setCodeAndMsg(Resp.Success.getCode(), Resp.Success.getMsg());
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), respCode + "-" + respDesc);
		}
		return rsp;
	}

	@Override
	public QueryCardInfoResp queryCardInfo(QueryCardInfoReq req) throws Exception {
		TradeStrategy ts = TradeStrategy.dao.selectFromRedis(req.getMerchCode(), PayType.QUICK_PAY_SET);
		String channelMerchCode = SystemConfig.channelConfig.get("YF_merchCode_" + ts.getChannelCode());
		QueryCardInfoResp rsp = new QueryCardInfoResp(req);
		HashMap<String, String> data = new HashMap<>();

		data.put("version", "1.0.0");
		data.put("merchantId", channelMerchCode);
		data.put("merchantUserId", req.getCertNo());
		YufuCipher cipher = YFUtil.getCipherInstance(ts.getChannelCode());
		TreeMap<String, String> sendData = YFUtil.getSendData(channelMerchCode, cipher.doPack(data));
		String sendResult = YFUtil.doPost(QUERY_CARD_INFO_URL, sendData);
		sendResult = URLDecoder.decode(sendResult, YFUtil.CHART_SET);
		JSONObject obj = JSONObject.parseObject(sendResult);
		Map<String, String> retBizData = cipher
				.unPack(new ParamPacket(obj.getString("data"), obj.getString("enc"), obj.getString("sign")));
		FSLog.api.info("-------- YF快捷支付查询卡信息请求响应解密 -------\r\n" + retBizData);
		String respCode = retBizData.get("respCode");
		String respDesc = retBizData.get("respDesc");
		if ("0000".equals(respCode)) {
			String cardInfoList = retBizData.get("cardInfoList");
			String merchantUserId = retBizData.get("merchantUserId");
			rsp.setCardInfoList(cardInfoList);
			rsp.setCertNo(merchantUserId);
			rsp.setCodeAndMsg(Resp.Success.getCode(), Resp.Success.getMsg());
		} else {
			rsp.setCodeAndMsg(Resp.Fail.getCode(), respCode + "-" + respDesc);
		}
		return rsp;
	}

}
